const btn = this.document.querySelector('#btn')
const { BrowserWindow,Menu } = require('@electron/remote')

window.onload = function(){
    btn.onclick = ()=>{
         newWin = new BrowserWindow({
             width:500,
             height:500,
         })
         newWin.loadFile('yellow.html')
         newWin.on('close',()=>{newWin=null})
     }
}

var rightMenu=[
    {
        label:'复制'
    },
    {
        label:'粘贴'
    }
]
// 构建右键菜单
var menu = Menu.buildFromTemplate(rightMenu);
// 为demo2的页面添加事件监听
window.addEventListener('contextmenu',function(e){
    // 阻止当前窗口默认事件
    e.preventDefault();
    // 把菜单模板添加到右键菜单
    menu.popup()
})